/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package di.server.log;

import di.server.config.DIInterceptor;
import java.io.PrintStream;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;

/**
 *
 * @author Kilian Ito
 */
public class Debug {
    
    protected static final boolean debugMode = true;
    private static final Logger logger = Logger.getLogger(Debug.class);
    
    /**
     * Write a debug message in the console
     * @param o 
     */
    public static void print(Object o) {
        print(o, false);
    }
    
    /**
     * Write a debug message in the Error console
     * @param o 
     */
    public static void printError(Object o) {
        print(o, true);
    }
    
    /**
     * Write a debug message in the console
     * @param o 
     */
    public static void print(Exception e) {
        logger.log(Level.FATAL, "Exception", e);
    }
    
    /**
     * Write a debug message in the console
     * @param o 
     */
    public static void print(Object o, boolean errorMessage) {
        consolePrint(o, errorMessage);
    }
    
    private static void consolePrint(Object o, boolean errorMessage) {
        if (errorMessage)
            logger.log(Level.ERROR, o);
        else 
            logger.log(Level.INFO, o);
    }
    
    /**
     * Mode debug is on
     * @return 
     */
    public static boolean isDebugMode() {
        return debugMode;
    }
}
